{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Pandas 数据处理常用函数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- `.head()`\n",
    "- `.info()`\n",
    "- `.describe()`\n",
    "- `.astype()`: 修改变量类型\n",
    "- `.rename()`\n",
    "- `.set_index()`\n",
    "- `.reset_index()`\n",
    "- `.drop()`\n",
    "- `.isin([])`\n",
    "- `.between()`\n",
    "- `.value_counts()`  统计分类变量中每一类的数量\n",
    "  - 参数：\n",
    "    - normalize (boolean, default False) 返回各类占比\n",
    "    - sort (boolean, default True) 对统计结果进行排序\n",
    "    - ascending （boolean, default False）是否升序排列\n",
    "- `is.na()`\n",
    "- `.any()`  i.e. df.isna().any()\n",
    "- `.dropna()`\n",
    "- `.fillna()`\n",
    "  - 参数\n",
    "    - value: 填充缺失值的值\n",
    "    - method: {‘backfill’, ‘bfill’, ‘pad’, ‘ffill’, None}, default None） 缺失值的填充方式，bfill: 使用后面的值进行填充，ffill用前面的值进行填充\n",
    "    - inplace\n",
    "- `.sort_index()`\n",
    "- `.sort_values()`\n",
    "- `pd.cut()`: 数据离散化，比如将人的年龄划分为各个区间\n",
    "- `pd.qcut()`: 使用分位数进行区间划分\n",
    "- `.where()`: 将不符合条件的值替换掉成指定值,符合条件值不变\n",
    "  - df['score'].where(df.score<=100, 100)\n",
    "- `pd.concat()`\n",
    "- `.pivot_table()`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- dir(df) # 查看属性"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "b3ba2566441a7c06988d0923437866b63cedc61552a5af99d1f4fb67d367b25f"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 ('base')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
